package com.quoc.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class CreateDatabases extends SQLiteOpenHelper {
	public static final String DB_NAME = "dbemployees";
	public static final int DB_VERSION = 1;

	public static final String tbEmployee = "tbEmployee";
	public static final String idEmployee = "_idEmployee";
	public static final String nameEmployee = "nameEmployee";
	public static final String officer = "officer";
	public static final String fkOffice = "fkOfice";
	public static final String sex = "sex";

	public static final String tbOffice = "tboffice";
	public static final String nameOffice = "nameoffice";
	public static final String idOffice = "idoffice";

	public static final String DB_CREATE_TBOFFICE = "CREATE TABLE " + tbOffice
			+ "(" + idOffice + " INTEGER PRIMARY KEY AUTOINCREMNET," + nameOffice
			+ " TEXT NOT NULL" + ")";
	public static final String DB_CREATE_TBEMPLOYEE = "create table "
			+ tbEmployee + "(" + idEmployee
			+ " integer primary key autoincrement, " + nameEmployee + " text, "
			+ officer + " text," + sex + " text,"+fkOffice+" integer," + "foreign key (" + fkOffice
			+ ")"+" references " + tbOffice + " (" + idOffice + "))";

	public CreateDatabases(Context context) {

		super(context, DB_NAME, null, DB_VERSION);
		Log.i("21106", "create class ");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.i("21106", "create database");
		db.execSQL(DB_CREATE_TBOFFICE);
		db.execSQL(DB_CREATE_TBEMPLOYEE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {

	}

}
